function displayGeneralTab() {
	mcTabs.displayTab("general_tab","general_panel");
	$("insert").disabled = "";
}
function displayUploadTab() {
	mcTabs.displayTab("upload_tab","upload_panel");
	$("insert").disabled = "disabled";
	$("upload").focus();
}

function uploadPrompt(html) {
	$("uploadPrompt").innerHTML = html;
}
function errMessage(msg) {
    var html = "<center><img src=\"" + ZTL.staticUrl + "/img/error.gif\"/><span style=\"color:#ff0000;\"> " + msg + "</span></center>"
    uploadPrompt(html);
}
function uploadIndicator(msg) {
    var html = "<center><img src=\"" + ZTL.staticUrl + "/img/indicator.gif\"/><span> " + msg + "</span></center>"
    uploadPrompt(html);
}
function clearUploadPrompt() {
	uploadPrompt("");
}

function uploadimage(fileInput) {
	var supportFormats = {"jpg":1,"jpeg":1,"gif":1,"png":1,"bmp":1};
	var fileName = fileInput.value;
	var validImg = true;
	var lastIndexOfDot = fileName.lastIndexOf(".");
	var extName = "jpg";
	if (lastIndexOfDot == -1) {
		validImg = false;
	}
	else {
		extName = fileName.substring(lastIndexOfDot + 1).toLowerCase();
		if (!supportFormats[extName]) {
			validImg = false;
		}
	}
	if (!validImg) {
		errMessage("只支持jpg、gif、png或bmp格式的图片！");
		return;
	}
	clearUploadPrompt();
	var form = fileInput.form;
	if (form) {
		uploadIndicator("正在上传图片，请稍等。。。");
		$("imgtype").value = extName;
		form.submit();
	}
}
